# -*- coding: utf-8 -*-


class Transformer:
    def transform_def_to_var_lambda(self, def_exp):
        _tag, name, params, body = def_exp
        return ['var', name, ['lambda', params, body]]

    def transform_switch_to_if(self, switch_exp):
        _tag, *cases = switch_exp
        if_exp = ['if', None, None, None]

        cur = if_exp
        for i in range(len(cases) - 1):
            cur_cond, cur_block = cases[i]
            cur[1], cur[2] = cur_cond, cur_block
            nxt_cond, nxt_block = cases[i + 1]
            if nxt_cond == 'else':
                cur[3] = nxt_block
            else:
                cur[3] = ['if', None, None, None]
            cur = cur[3]

        return if_exp

    def transform_for_to_while(self, for_exp):
        pass
